﻿<!--#include file="const.inc"-->
<%
'====================================================================
' 感谢使用晴天3G智能建站系统..
' 作者:梁永强.QQ:766750857
' 官方网址:wap.qt3g.com
' 声明:软件版权归作者所有,没有经过作者本人同意不得非法破解和传播本程序
'====================================================================
%>
<%
if sid="Null" then Response.Redirect "/login.asp?sid="&sidd&"&url=/game/21/index.asp"
IF  Request.QueryString("Action")="login" Then
	call loginn
else
	call index
end if
end Function

Function index
        dim pid,mon,body
	pid=Request.QueryString("pid")
	if pid="" then pid=1
	if not isnumeric(pid) then pid=1
	pid=clng(pid)
        mon=sangong.namejian("money",pid)
select case v
case "0"
we0="<br/>"
hr="----------------<br/>"
body="下注<a href='gamedd.asp?pid="&pid&"&amp;midd="&int(mon/5)&"&amp;Action=login&amp;sid=" & sidd & "'>"&int(mon/5)&"</a>.<a href='gamedd.asp?pid="&pid&"&amp;midd="&int(mon/2)&"&amp;Action=login&amp;sid=" & sidd & "'>"&int(mon/2)&"</a>.<a href='gamedd.asp?pid="&pid&"&amp;midd="&mon&"&amp;Action=login&amp;sid=" & sidd & "'>"&mon&"</a><br/><input name='midd' format='*N' size='15' maxlength='10'/><br/>最高不能超过"&mon&"<br/><anchor>下注<go href='gamedd.asp?pid="&pid&"&amp;Action=login&amp;sid="&sidd&"' method='post'><postfield name=""midd"" value=""$(midd:n)"" /></go></anchor><br/>"
%>
<card id="main" title="决战21点"><p align="<%=qingtian.px%>">
<%
case "1"
zi="<span style=""color:#FF5500"">"
zi0="</span>"
we="<div class=""footer"">"
sou="<div class=""block4"">"
dao="<div class=""navi"">"
we0="</div>"
we1="</div>"
ziz="<div style=""background-color:#FF5226;font-size:16px;color:#E1E100"">"
body="<div class=""footer"">下注<a href='gamedd.asp?pid="&pid&"&amp;midd="&int(mon/5)&"&amp;Action=login&amp;sid=" & sidd & "'>"&int(mon/5)&"</a>.<a href='gamedd.asp?pid="&pid&"&amp;midd="&int(mon/2)&"&amp;Action=login&amp;sid=" & sidd & "'>"&int(mon/2)&"</a>.<a href='gamedd.asp?pid="&pid&"&amp;midd="&mon&"&amp;Action=login&amp;sid=" & sidd & "'>"&mon&"</a></div><form action='gamedd.asp?pid="&pid&"&amp;Action=login&amp;sid="&sidd&"' method='post'><input emptyok='true' format='*N' type='text' name='midd' value='' size='15'/><br/><div class=""block4"">最高不能超过"&mon&"</div><input type='submit' value='下注'/></form><br/>"
%>
<title>决战21点</title>
</head>
<body>
<!--#include virtual="/css.inc"-->
<%
End Select
%>
<%=ziz%>★★我要下注★★<%=we0%><%=body%>
<%=we%>账户:<%=zi%><%=conn.execute("select money from [qingtian_user] where sid='"&qingtian.Formatsid(sid)&"'")("money")%><%=qingtian.bi%><%=zi0%><%=we0%><%=sou%>
<a href="main2.asp?sid=<%=sidd%>">返回上级</a>.<a href="/game/21/index.asp?sid=<%=sidd%>">决战21点</a><%=we0%>

<%
end Function

Function loginn

dim id,a,b,nid,rs,sql,i,d,rss,sqls,mynid,mon,midd,pid
	act=Request.QueryString("act")
	if act="" then act=0
	if not isnumeric(act) then act=0
	act=clng(act)
	pid=Request.QueryString("pid")
	if pid="" then pid=1
	if not isnumeric(pid) then pid=1
	pid=clng(pid)
	id=100000
mynid=qingtian.nid
select case v
case "0"
we0="<br/>"
hr="----------------<br/>"
%>
<card id="main" title="决战21点"><p align="<%=qingtian.px%>">
<%
case "1"
zi="<span style=""color:#FF5500"">"
zi0="</span>"
we="<div class=""footer"">"
sou="<div class=""block4"">"
dao="<div class=""navi"">"
we0="</div>"
we1="</div>"

ziz="<div style=""background-color:#FF5226;font-size:16px;color:#E1E100"">"
%>
<title>决战21点</title>
</head>
<body>
<!--#include virtual="/css.inc"-->
<%
End Select
if act=4 then
        if sangong.namere("b",mynid)=0 then
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select top 1 * FROM qingtian_reton where nid="&mynid&" order by id asc"
	Rs.Open Sql,cn,1,3
		if not (rs.bof and rs.eof)  then 
                rs("ton")=0
                rs("time")=now()
                rs("aid")=0
                rs("bid")=0
                rs("ku")=0
                rs("a")=0
                rs("c")=""
                rs("a1")=0
                rs("c1")=""
                rs("h")=""
                rs("d")=0
                rs("b")=0
	rs.update
Response.Redirect "main2.asp?sid="&sidd&"&id="&pid
        end if
	Rs.close
       set rs=nothing
else
qingtian.err("游戏正在进行中不能退出")
end if
end if
        mon=sangong.namejian("money",pid)
	midd=Request("midd")
	if midd="" then midd=10
	if not isnumeric(midd) then midd=10
	midd=clng(midd)
        middd=conn.execute("select money from [qingtian_user] where sid='"&qingtian.Formatsid(sid)&"'")("money")
        if middd<2*midd then qingtian.err("下注金额不能超过"&int(middd/2)&"") 
        if midd>mon then qingtian.err("下注金额不能超过"&mon&"")
qingtian.info
toname=cn.execute("select toname from [qingtian_fangjian] where id="&pid&"")("toname")
if sangong.namere("aid",mynid)<>0 and sangong.namere("aid",mynid)<>id then
qingtian.err("你还在游戏中<a href='gamed.asp?pid="&pid&"&amp;id="&sangong.namere("aid",mynid)&"&amp;action=login&amp;sid=" & sidd & "'>返回继续游戏</a>")
end if 
sangong.pd(pid)
%>
<%=ziz%>☆决战21点☆<%=we0%>
<%=dao%><%=toname%> ＰＫ　<%=qingtian.utf8(session("username"))%><%=we0%><%=hr%><%=we%>
<%
        if sangong.namere("b",mynid)=0 then 
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select top 1 * FROM qingtian_reton where nid="&mynid&" order by id asc"
	Rs.Open Sql,cn,1,3
		if not (rs.bof and rs.eof)  then 
                rs("ton")=1
                rs("time")=now()
                rs("aid")=id
                rs("bid")=pid
                rs("b")=1
                rs("money")=midd
	rs.update
        end if
	Rs.close
       set rs=nothing
       sangong.game2()
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select top 1 * FROM qingtian_reton where nid="&mynid&" order by id asc"
	Rs.Open Sql,cn,1,1
		if not (rs.bof and rs.eof)  then  
                a=rs("a1")
                ku=rs("ku")
                end if
	Rs.close
       set rs=nothing 
       if ku=true then
       Response.Write sangong.gamejie2(pid)
       else
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select top 1 * FROM qingtian_reton where nid="&mynid&" order by id asc"
	Rs.Open Sql,cn,1,1
		if not (rs.bof and rs.eof)  then
                if rs("a")=1000 then 
                aa="黑杰克"
                else
                aa=rs("a")&"点"
                end if
                if rs("a1")=1000 then 
                aa1="黑杰克"
                else
                aa1="kong"
                end if
                Response.Write(""&toname&"的牌"&zi&"(庄)"&zi0&"："&zi&""&aa1&""&zi0&"<br/>"&sangong.aapai(rs("c1"))&"<br/>")  
                Response.Write("你的牌："&zi&""&aa&""&zi0&"<br/>"&sangong.pai(rs("c"))&"<br/>")                
                end if
       Rs.close
       set rs=nothing
                Response.Write("<a href='gamedd.asp?Action=login&amp;pid="&pid&"&amp;act=1&amp;sid="&sidd&"'>要牌</a>.<a href='gamedd.asp?Action=login&amp;pid="&pid&"&amp;act=2&amp;sid="&sidd&"'>翻陪</a>.<a href='gamedd.asp?Action=login&amp;pid="&pid&"&amp;act=3&amp;sid="&sidd&"'>停牌</a>.<a href='gamedd.asp?Action=login&amp;pid="&pid&"&amp;sid="&sidd&"'>刷新</a><br/>") 
          end if
else
       select case act
       case "1"  
       sangong.yaopai1("0")       
       case "2"
       c=split(sangong.namere("c",mynid),",")  
       if sangong.namere("ku",mynid)=1 or Ubound(c)<>1 then
          Response.Write("翻陪失败请[<a href='gamed.asp?Action=login&amp;id="&id&"&amp;pid="&pid&"&amp;sid="&sidd&"'>刷新</a>]<br/>")
       else
       sangong.yaopai1("0") 
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select top 1 * FROM qingtian_reton where nid="&mynid&" order by id asc"
	Rs.Open Sql,cn,1,3
		if not (rs.bof and rs.eof)  then 
                rs("ku")=1
                rs("money")=rs("money")*2
	rs.update
        end if
	Rs.close
        set rs=nothing 
       end if
       case "3"
       cn.Execute("update qingtian_reton set ku=1 where nid="&mynid) 
       End Select 
       if sangong.namere("ku",mynid)=true then
       for i=1 to 11
       if sangong.namere("a1",mynid)<17 and sangong.namere("a",mynid)<22 then sangong.yaopai1("1") 
       next 
       Response.Write sangong.gamejie2(pid)
       else         
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select top 1 * FROM qingtian_reton where nid="&mynid&" order by id asc"
	Rs.Open Sql,cn,1,1
		if not (rs.bof and rs.eof)  then
                if rs("a")=1000 then 
                aa="黑杰克"
                else
                aa=rs("a")&"点"
                end if
                if rs("a1")=1000 then 
                aa1="黑杰克"
                else
                aa1="kong"
                end if
                Response.Write(""&toname&"的牌"&zi&"(庄)"&zi0&"："&zi&""&aa1&""&zi0&"<br/>"&sangong.aapai(rs("c1"))&"<br/>")  
                Response.Write("你的牌："&zi&""&aa&""&zi0&"<br/>"&sangong.pai(rs("c"))&"<br/>")                
                end if
       Rs.close
       set rs=nothing
                Response.Write("<a href='gamedd.asp?Action=login&amp;pid="&pid&"&amp;act=1&amp;sid="&sidd&"'>要牌</a>.<a href='gamedd.asp?Action=login&amp;act=3&amp;pid="&pid&"&amp;sid="&sidd&"'>停牌</a>.<a href='gamedd.asp?Action=login&amp;pid="&pid&"&amp;sid="&sidd&"'>刷新</a><br/>") 
       end if
       end if
%>
<%=we1%><%=hr%><%=sou%>账户:<%=zi%><%=conn.execute("select money from [qingtian_user] where sid='"&qingtian.Formatsid(sid)&"'")("money")%><%=zi0%><%=qingtian.bi%><%=we0%><%=ziz%><a href="main2.asp?sid=<%=sidd%>">返回上级</a>.<a href="/game/21/index.asp?sid=<%=sidd%>">决战21点</a><%=we0%>

<%
end function
%>